package com.school.aftersalemanagement.controller.ui.set;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.school.aftersalemanagement.R;
import com.school.aftersalemanagement.entity.Bike;
import com.school.aftersalemanagement.global.BaseToolBarActivity;
import com.school.aftersalemanagement.service.BicycleService;
import com.school.aftersalemanagement.service.impl.BicycleServiceimpl;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class SetActivity extends BaseToolBarActivity {
    @BindView(R.id.setTimes)
    EditText setTimes;
    @BindView(R.id.getTimes)
    TextView getTimes;
    private BicycleService bicycleService;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        setToolbarText("设置");
        bicycleService = new BicycleServiceimpl(this,mHandler);
    }

    @Override
    protected void onResume() {
        super.onResume();
        bicycleService.getRemindingTimes(getTime);
    }

    private int getTime = 1;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
           if(msg.what==getTime){
               String str = (String)msg.obj;
               if(str!=null)
                   getTimes.setText(str);
           }
        }
    };
    @OnClick(R.id.setSure)
    public void onViewClicked(View view){
        switch (view.getId()){
            case R.id.setSure:
                bicycleService.setWarnTimes(0,setTimes.getText().toString());
                break;
        }
    }
}
